//remove space, include head and last
function trim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

function seleAll(ckBoxName, myChecked)
{
	names = document.getElementsByName(ckBoxName);
	for(var i = 0; i < names.length; i++)
	{
		names[i].checked = myChecked
	}
}

function getCheckboxValue(ckBoxName)
{
	var ckBoxValue = "";
	names = document.getElementsByName(ckBoxName);
	for(var i = 0; i < names.length; i++)
	{
		if(names[i].checked == true)
		{
			ckBoxValue += names[i].value+",";
		}
	}
	if(ckBoxValue != "")
		ckBoxValue = ckBoxValue.substring(0, ckBoxValue.length-1);
	return ckBoxValue;
}

function delBatch()
{
	var ckValues = "";
	ckValues = getCheckboxValue("myId");
	if(ckValues == "")
	{
		alert('请至少选择一项');
		return false;
	}
	var flag = confirm('确定要删除吗？');
	if(!flag)
		return false;
	document.location.href = "delBatch?batchIds="+ckValues;
	return false;
}

function doQuery()
{
	var nametj = trim(document.all.nametj.value);
	nametj = encodeURI(nametj);
	location.href = "list?nametj="+nametj;
}

//deal select which item is selected
function dealSeleItem(seleId, seleValue)
{
	var allOptions = document.getElementById(seleId).options;

    for(i=0; i<allOptions.length; i++)
	{
 		if(document.getElementById(seleId).options[i].value == seleValue)
 	 	{
 	    	document.getElementById(seleId).options[i].selected=true;
 	   	}
	}
}


